import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "index",
  },
  {
    path: "/index",
    name: "index",
    component: () => import("@/views/index.vue"),
  },
  {
    path: "/event-exchange",
    name: "communicate",
    component: () => import("@/views/communicate.vue"),
  },
  {
    path: "/popular-events",
    name: "popular-events",
    component: () => import("@/views/event.vue"),
  },
  {
    path: "/eventList",
    name: "eventList",
    component: () => import("@/views/eventList.vue"),
  },
  {
    path: "/eventDetail",
    name: "eventDetail",
    component: () => import("@/views/eventDetail.vue"),
  },
  {
    path: "/aboutus",
    name: "about",
    component: () => import("@/views/about.vue"),
  },
  {
    path: "/photographer",
    name: "photographer",
    component: () => import("@/views/cameraman.vue"),
  },
  {
    path: "/cameramanDetail",
    name: "cameramanDetail",
    component: () => import("@/views/cameramanDetail.vue"),
  },
  {
    path: "/disclaimer",
    name: "disclaimer",
    component: () => import("@/views/disclaimer"),
  },
  {
    path: "/user",
    name: "user",
    component: () => import("@/views/user/index.vue"),
    redirect: "/user/user",
    children: [
      {
        path: "user",
        name: "user2",
        component: () => import("@/views/user/user.vue"),
      },
      {
        path: "auth",
        name: "auth",
        component: () => import("@/views/user/auth.vue"),
      },
      {
        path: "withdrawal",
        name: "withdrawal",
        component: () => import("@/views/user/withdrawal.vue"),
      },
      {
        path: "recharge",
        name: "recharge",
        component: () => import("@/views/user/recharge.vue"),
      },
      {
        path: "message",
        name: "message",
        component: () => import("@/views/user/message.vue"),
      },
      {
        path: "follow",
        name: "follow",
        component: () => import("@/views/user/follow.vue"),
      },
      {
        path: "collect",
        name: "collect",
        component: () => import("@/views/user/collect.vue"),
      },
      {
        path: "works",
        name: "works",
        component: () => import("@/views/user/works.vue"),
      },
      {
        path: "record",
        name: "record",
        component: () => import("@/views/user/record.vue"),
      },
    ],
  },
];
// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题

const router = new VueRouter({
  routes,
  mode: "history",
  scrollBehavior() {
    return {
      x: 0,
      y: 0,
    };
  },
});
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};
export default router;
